<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Tree树状图</title>
    <!-- 引入echarts库文件 -->
    <script src="../static_js/echarts.min.js"></script>
    <!-- 引入jquery库文件 -->
    <script src="../static_js/jquery.js"></script>
    <!--    链接外部CSS样式表-->
    <link rel="stylesheet" href="./CSS/mystyle.css" />


</head>
<body>
<!--搜索框区域-->
<div id="container" class="center-justify">
    <div class="sea-container">
        <form action="">
            <input type="text" name="search" class="blue-input" >

            <input type="submit"  value="搜索" class="blue-button">
        </form>
        <p id="selectedId"></p>
    </div>
</div>
<!--    添加搜索js-->
<script src="js/search.js" type="text/javascript" charset="utf-8"></script>


<!-- 定义图表现实区域 -->
<div id="main" style="top:50px; width:1200px; height: 600px"></div>

<script type="text/javascript">
    <!-- 初始化echarts对象 -->

    var chartDom = document.getElementById('main');
    var myChart = echarts.init(chartDom);
    var option;

    myChart.showLoading();
    $.get('./data/test.json', function (data) {
        myChart.hideLoading();

        data.children.forEach(function (datum, index) {
            index % 2 === 0 && (datum.collapsed = true);
        });

        myChart.setOption(option = {
            tooltip: {
                trigger: 'item',
                triggerOn: 'mousemove'
            },
            series: [
                {
                    type: 'tree',

                    data: [data],

                    top: '1%',
                    left: '7%',
                    bottom: '1%',
                    right: '20%',

                    symbolSize: 7,

                    label: {
                        position: 'left',
                        verticalAlign: 'middle',
                        align: 'right',
                        fontSize: 9
                    },

                    leaves: {
                        label: {
                            position: 'right',
                            verticalAlign: 'middle',
                            align: 'left'
                        }
                    },

                    emphasis: {
                        focus: 'descendant'
                    },

                    expandAndCollapse: true,
                    animationDuration: 550,
                    animationDurationUpdate: 750
                }
            ]
        });
    });

    option && myChart.setOption(option);


</script>
</body>
</html>